/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistencia;

import com.thoughtworks.xstream.XStream;
import java.io.*;
import mundo.GestorMapas;

/**
 *
 * @author Yanire
 */

public class Serializacion {
    private Partida partida;

    public Serializacion() {

    }
    
    public void Serializacion(GestorMapas gestor, String nombreArch){
        XStream xstream = new XStream();
        partida = new Partida(gestor);


        String xml = xstream.toXML(partida);

        try {
            FileWriter fw = new FileWriter(nombreArch);
            fw.write(xml);
            fw.close();
        } catch (IOException e) {
            System.out.println(e.toString());
        }

    }

    public Partida Deserializacion(String nombreArch){
       
        try {
            XStream xs = new XStream();
            FileReader fr = new FileReader(nombreArch);
            partida = (Partida)xs.fromXML(fr);
            fr.close();
        } catch (IOException e) {
            System.out.println(e.toString());
        }

        return partida;
    }

}
